# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=libretro-dolphin
pkgver=33042
pkgrel=1
pkgdesc='Nintendo GC/Wii core'
arch=(loong64 x86_64)
url=https://github.com/libretro/dolphin
license=(GPL2)
groups=(libretro)
depends=(
  bluez-libs
  bzip2
  enet
  gcc-libs
  glibc
  libevdev
  libfmt.so
  libgl
  libglvnd
  libhidapi-hidraw.so
  libmbedcrypto.so
  libmbedtls.so
  libmbedx509.so
  libpng
  libretro-core-info
  libudev.so
  libusb-1.0.so
  libx11
  libxi
  libxrandr
  lzo
  sfml
  xz
  zlib
  zstd
)
makedepends=(
  clang
  cmake
  git
  mesa
  ninja
  python
)
_commit=2f4b0f7902257d40a054f60b2c670d6e314f2a04
source=(
  libretro-dolphin::git+https://github.com/libretro/dolphin.git#commit=${_commit}
  libretro-dolphin-missing-headers.patch
)
b2sums=('SKIP'
        '5b4ca6d1dc6af7a3afd014700305616d9e3e0f139f128cfa2af6cff3194a36ef9a591faaefbb8491d71f646187ee79e6fb5f29e9f57eeaf4e82768e814516f1a')

prepare() {
  cd libretro-dolphin
  patch -Np1 -i ../libretro-dolphin-missing-headers.patch
}

pkgver() {
  cd libretro-dolphin

  git rev-list --count HEAD
}

build() {
  export CC=clang
  export CXX=clang++
  cmake -S libretro-dolphin -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DENABLE_LTO=ON \
    -DENABLE_NOGUI=OFF \
    -DENABLE_QT=OFF \
    -DENABLE_TESTS=OFF \
    -DLIBRETRO=ON \
    -DUSE_SHARED_ENET=ON \
    -Wno-dev
  cmake --build build
}

package() {
  install -Dm 644 build/dolphin_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
